﻿/*******************************************************
* Copyright (c) 2018-2088, By XuXiang all rights reserved.
*
* FileName: ConfigWrap.h
* Summary: 配置基类。
*
* Author: XuXiang
* Date: 2024-05-09 23:11
*******************************************************/

#ifndef __ConfigWrap_h__
#define __ConfigWrap_h__

#include <string>
#include <vector>
#include <assert.h>
using namespace std;

namespace Competition
{
	class CSVLoader;

	class ConfigWrap
	{
	public:
		ConfigWrap();
		virtual ~ConfigWrap();

		//创建新对象
		template<class T>
		static ConfigWrap* OnNew();

		//获取唯一标识
		virtual int GetUniqueKey() = 0;

		//读取数据
		virtual void Read(CSVLoader* loader) = 0;

		//二次解析
		virtual void OnParse() {};

	private:
	};

	template<class T>
	ConfigWrap* ConfigWrap::OnNew()
	{
		T *t = new T();
		ConfigWrap *wrap = dynamic_cast<ConfigWrap*>(t);
		assert(wrap != NULL);
		return wrap;
	}
}

#endif
